﻿using PGMHelper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using WSAP;

namespace MDOF
{
    public partial class MDOFForm : Form
    {

        /// <summary>
        /// 结构
        /// </summary>
        private Structure Struct { set; get; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public MDOFForm()
        {
            InitializeComponent();
            this.Struct = new Structure();
            this.GridView.SetApperance(DataGridViewSelectionMode.FullColumnSelect);
        }

        /// <summary>
        /// 质量
        /// </summary>
        private double mass
        {
            get
            {
                return Convert.ToDouble(this.MassTextbox.Text);
            }
        }

        /// <summary>
        /// 刚度
        /// </summary>
        private double stiffness
        {
            get
            {
                return Convert.ToDouble(this.StiffTextbox.Text);
            }
        }

        /// <summary>
        /// 模态分析数
        /// </summary>
        private int eigenNumber
        {
            get
            {
                return Convert.ToInt32(this.EigenNumberTextbox.Text);
            }
        }

        /// <summary>
        /// 添加楼层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddButton_Click(object sender, EventArgs e)
        {
            this.Struct.AddStorey(this.stiffness, this.mass);
            this.GridView.AddDatas(this.Struct.GetData());
        }

        /// <summary>
        /// 清空楼层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ClearButton_Click(object sender, EventArgs e)
        {
            this.Struct.Clear();
            this.GridView.AddDatas(this.Struct.GetData());
        }

        /// <summary>
        /// 模态分析
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EigenButton_Click(object sender, EventArgs e)
        {
            StructrueChart.ModeID = Convert.ToInt32(this.ModeShowTextbox.Text);
            StructrueChart.ModeID = StructrueChart.ModeID <= this.eigenNumber ?
                StructrueChart.ModeID : this.eigenNumber;
            this.Struct.DoEigen(this.eigenNumber);
        }
    }
}
